package net.freebytes.chat2;

import io.netty.channel.Channel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @description:
 * @author: lin
 * @time: 2024/12/3 23:51
 */
public class ChannelSessionMemory {

    private static final Map<String, Channel> map = new HashMap<>();
    private static final List<String> waitingUsers = new ArrayList<>();


    private static String rgChannelId;


    public static void putClientChannel(String id, Channel channel) {
        map.put(id, channel);
    }

    public static String getRgChannelId() {
        return rgChannelId;
    }

    public static String getWaitingUser() {
        return map.keySet().stream().findAny().orElse(null);
    }

    public static void putRg(String channelId) {
        rgChannelId = channelId;
    }

    public static Channel getClientChannel(String id) {
        return map.get(id);
    }

    public static void putWaitingUser(String uChannelId) {
        waitingUsers.add(uChannelId);
    }

    public static void deleteWaitingUser(String uChannelId) {
        map.remove(uChannelId);
        waitingUsers.remove(uChannelId);
    }
}
